library("FRESA.CAD")
library(readxl)
library(igraph)
library(umap)
library(tsne)
library(entropy)
op <- par(no.readonly = TRUE)
pander::panderOptions('digits', 3)
pander::panderOptions('table.split.table', 400)
pander::panderOptions('keep.trailing.zeros',TRUE)
Data from the speech features
pd_speech_features <- as.data.frame(read_excel("~/GitHub/FCA/Data/pd_speech_features.xlsx",sheet = "pd_speech_features", range = "A2:ACB758"))
Each subject had three repeated observations. Here I’ll use the average of the three experiments per subject.
rep1Parkison <- subset(pd_speech_features,RID==1)
rownames(rep1Parkison) <- rep1Parkison$id
rep1Parkison$id <- NULL
rep1Parkison$RID <- NULL
rep1Parkison[,1:ncol(rep1Parkison)] <- sapply(rep1Parkison,as.numeric)
rep2Parkison <- subset(pd_speech_features,RID==2)
rownames(rep2Parkison) <- rep2Parkison$id
rep2Parkison$id <- NULL
rep2Parkison$RID <- NULL
rep2Parkison[,1:ncol(rep2Parkison)] <- sapply(rep2Parkison,as.numeric)
rep3Parkison <- subset(pd_speech_features,RID==3)
rownames(rep3Parkison) <- rep3Parkison$id
rep3Parkison$id <- NULL
rep3Parkison$RID <- NULL
rep3Parkison[,1:ncol(rep3Parkison)] <- sapply(rep3Parkison,as.numeric)
whof <- !(colnames(rep1Parkison) %in% c("gender","class"));
avgParkison <- rep1Parkison;
avgParkison[,whof] <- (rep1Parkison[,whof] + rep2Parkison[,whof] + rep3Parkison[,whof])/3
signedlog <- function(x) { return (sign(x)*log(abs(1.0e12*x)+1.0))}
whof <- !(colnames(avgParkison) %in% c("gender","class"));
avgParkison[,whof] <- signedlog(avgParkison[,whof])
studyName <- "Parkinsons"
dataframe <- avgParkison
outcome <- "class"
TopVariables <- 10
thro <- 0.80
cexheat = 0.15
Some libraries
library(psych)
library(whitening)
library("vioplot")
library("rpart")
pander::pander(c(rows=nrow(dataframe),col=ncol(dataframe)-1))
| rows | col |
|---|---|
| 252 | 753 |
pander::pander(table(dataframe[,outcome]))
| 0 | 1 |
|---|---|
| 64 | 188 |
varlist <- colnames(dataframe)
varlist <- varlist[varlist != outcome]
largeSet <- length(varlist) > 1500
Scaling and removing near zero variance columns and highly co-linear(r>0.99999) columns
### Some global cleaning
sdiszero <- apply(dataframe,2,sd) > 1.0e-16
dataframe <- dataframe[,sdiszero]
varlist <- colnames(dataframe)[colnames(dataframe) != outcome]
tokeep <- c(as.character(correlated_Remove(dataframe,varlist,thr=0.99999)),outcome)
dataframe <- dataframe[,tokeep]
varlist <- colnames(dataframe)
varlist <- varlist[varlist != outcome]
iscontinous <- sapply(apply(dataframe,2,unique),length) >= 5 ## Only variables with enough samples
dataframeScaled <- FRESAScale(dataframe,method="OrderLogit")$scaledData
numsub <- nrow(dataframe)
if (numsub > 1000) numsub <- 1000
if (!largeSet)
{
hm <- heatMaps(data=dataframeScaled[1:numsub,],
Outcome=outcome,
Scale=TRUE,
hCluster = "row",
xlab="Feature",
ylab="Sample",
srtCol=45,
srtRow=45,
cexCol=cexheat,
cexRow=cexheat
)
par(op)
}
The heat map of the data
if (!largeSet)
{
par(cex=0.6,cex.main=0.85,cex.axis=0.7)
#cormat <- Rfast::cora(as.matrix(dataframe[,varlist]),large=TRUE)
cormat <- cor(dataframe[,varlist],method="pearson")
cormat[is.na(cormat)] <- 0
gplots::heatmap.2(abs(cormat),
trace = "none",
# scale = "row",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Original Correlation",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Pearson Correlation|",
xlab="Feature", ylab="Feature")
diag(cormat) <- 0
print(max(abs(cormat)))
}
[1]
0.9999951
DEdataframe <- IDeA(dataframe,verbose=TRUE,thr=thro)
#>
#> tqwt_maxValue_dec_8 det_LT_TKEO_mean_1_coef tqwt_skewnessValue_dec_1 tqwt_skewnessValue_dec_34 mean_delta_delta_0th tqwt_skewnessValue_dec_9
#> PPE DFA RPDE numPulses
#> 0.3198925 0.2836022 0.3037634 0.8534946
#> numPeriodsPulses meanPeriodPulses
#> 0.8494624 0.3830645
#>
#> Included: 744 , Uni p: 0.0002016129 , Base Size: 80 , Rcrit: 0.2212033
#>
#>
1 <R=1.000,thr=0.950>, Top: 74< 47 >[Fa= 74 ]( 74 , 256 , 0 ),<|><>Tot Used: 330 , Added: 256 , Zero Std: 0 , Max Cor: 1.000
#>
2 <R=1.000,thr=0.950>, Top: 36< 8 >[Fa= 109 ]( 36 , 95 , 74 ),<|><>Tot Used: 391 , Added: 95 , Zero Std: 0 , Max Cor: 0.999
#>
3 <R=0.999,thr=0.950>, Top: 19< 5 >[Fa= 127 ]( 18 , 42 , 109 ),<|><>Tot Used: 421 , Added: 42 , Zero Std: 0 , Max Cor: 0.999
#>
4 <R=0.999,thr=0.950>, Top: 3< 2 >[Fa= 130 ]( 3 , 6 , 127 ),<|><>Tot Used: 424 , Added: 6 , Zero Std: 0 , Max Cor: 0.950
#>
5 <R=0.950,thr=0.900>, Top: 74< 2 >[Fa= 162 ]( 71 , 92 , 130 ),<|><>Tot Used: 460 , Added: 92 , Zero Std: 0 , Max Cor: 0.981
#>
6 <R=0.981,thr=0.950>, Top: 2< 1 >[Fa= 162 ]( 2 , 2 , 162 ),<|><>Tot Used: 460 , Added: 2 , Zero Std: 0 , Max Cor: 0.949
#>
7 <R=0.949,thr=0.900>, Top: 12< 1 >[Fa= 165 ]( 11 , 13 , 162 ),<|><>Tot Used: 461 , Added: 13 , Zero Std: 0 , Max Cor: 0.978
#>
8 <R=0.978,thr=0.950>, Top: 1< 1 >[Fa= 165 ]( 1 , 1 , 165 ),<|><>Tot Used: 461 , Added: 1 , Zero Std: 0 , Max Cor: 0.912
#>
9 <R=0.912,thr=0.900>, Top: 2< 1 >[Fa= 165 ]( 2 , 2 , 165 ),<|><>Tot Used: 461 , Added: 2 , Zero Std: 0 , Max Cor: 0.900
#>
10 <R=0.900,thr=0.800>, Top: 76< 5 >[Fa= 191 ]( 70 , 119 , 165 ),<|><>Tot Used: 497 , Added: 119 , Zero Std: 0 , Max Cor: 0.956
#>
11 <R=0.956,thr=0.950>, Top: 1< 1 >[Fa= 191 ]( 1 , 1 , 191 ),<|><>Tot Used: 497 , Added: 1 , Zero Std: 0 , Max Cor: 0.948
#>
12 <R=0.948,thr=0.900>, Top: 4< 1 >[Fa= 193 ]( 4 , 4 , 191 ),<|><>Tot Used: 497 , Added: 4 , Zero Std: 0 , Max Cor: 0.900
#>
13 <R=0.900,thr=0.800>, Top: 23< 1 >[Fa= 198 ]( 21 , 27 , 193 ),<|><>Tot Used: 504 , Added: 27 , Zero Std: 0 , Max Cor: 0.921
#>
14 <R=0.921,thr=0.900>, Top: 1< 1 >[Fa= 199 ]( 1 , 1 , 198 ),<|><>Tot Used: 504 , Added: 1 , Zero Std: 0 , Max Cor: 0.900
#>
15 <R=0.900,thr=0.800>, Top: 7< 2 >[Fa= 200 ]( 7 , 8 , 199 ),<|><>Tot Used: 506 , Added: 8 , Zero Std: 0 , Max Cor: 0.834
#>
16 <R=0.834,thr=0.800>, Top: 2< 1 >[Fa= 200 ]( 2 , 2 , 200 ),<|><>Tot Used: 506 , Added: 2 , Zero Std: 0 , Max Cor: 0.799
#>
17 <R=0.799,thr=0.800>
#>
[ 17 ], 0.798067 Decor Dimension: 506 Nused: 506 . Cor to Base: 267 , ABase: 744 , Outcome Base: 0
#>
varlistc <- colnames(DEdataframe)[colnames(DEdataframe) != outcome]
pander::pander(sum(apply(dataframe[,varlist],2,var)))
57178
pander::pander(sum(apply(DEdataframe[,varlistc],2,var)))
55135
pander::pander(entropy(discretize(unlist(dataframe[,varlist]), 256)))
4.68
pander::pander(entropy(discretize(unlist(DEdataframe[,varlistc]), 256)))
3.21
varratio <- attr(DEdataframe,"VarRatio")
pander::pander(tail(varratio))
| La_app_entropy_shannon_5_coef | La_app_det_TKEO_mean_6_coef | La_app_LT_TKEO_mean_10_coef | La_app_det_TKEO_mean_8_coef | La_app_entropy_log_8_coef | La_app_LT_TKEO_mean_9_coef |
|---|---|---|---|---|---|
| 5.19e-05 | 3.63e-05 | 2.71e-05 | 1.08e-05 | 3.25e-06 | 2.64e-06 |
if (!largeSet)
{
par(cex=0.6,cex.main=0.85,cex.axis=0.7)
UPLTM <- attr(DEdataframe,"UPLTM")
gplots::heatmap.2(1.0*(abs(UPLTM)>0),
trace = "none",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Decorrelation matrix",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Beta|>0",
xlab="Output Feature", ylab="Input Feature")
par(op)
}
Displaying the features associations
par(op)
clustable <- c("To many variables")
transform <- attr(DEdataframe,"UPLTM") != 0
tnames <- colnames(transform)
colnames(transform) <- str_remove_all(colnames(transform),"La_")
transform <- abs(transform*cor(dataframe[,rownames(transform)])) # The weights are proportional to the observed correlation
fscore <- attr(DEdataframe,"fscore")
VertexSize <- fscore # The size depends on the variable independence relevance (fscore)
names(VertexSize) <- str_remove_all(names(VertexSize),"La_")
VertexSize <- 10*(VertexSize-min(VertexSize))/(max(VertexSize)-min(VertexSize)) # Normalization
VertexSize <- VertexSize[rownames(transform)]
rsum <- apply(1*(transform !=0),1,sum) + 0.01*VertexSize + 0.001*varratio[tnames]
csum <- apply(1*(transform !=0),2,sum) + 0.01*VertexSize + 0.001*varratio[tnames]
ntop <- min(10,length(rsum))
topfeatures <- unique(c(names(rsum[order(-rsum)])[1:ntop],names(csum[order(-csum)])[1:ntop]))
rtrans <- transform[topfeatures,]
csum <- (apply(1*(rtrans !=0),2,sum) > 1*(colnames(rtrans) %in% topfeatures))
rtrans <- rtrans[,csum]
topfeatures <- unique(c(topfeatures,colnames(rtrans)))
print(ncol(transform))
[1] 506
transform <- transform[topfeatures,topfeatures]
print(ncol(transform))
[1] 221
if (ncol(transform)>100)
{
csum <- apply(1*(transform !=0),1,sum)
csum <- csum[csum > 1]
csum <- csum + 0.01*VertexSize[names(csum)]
csum <- csum[order(-csum)]
tpsum <- min(20,length(csum))
trsum <- rownames(transform)[rownames(transform) %in% names(csum[1:tpsum])]
rtrans <- transform[trsum,]
topfeatures <- unique(c(rownames(rtrans),colnames(rtrans)))
transform <- transform[topfeatures,topfeatures]
if (nrow(transform) > 150)
{
csum <- apply(1*(rtrans != 0 ),2,sum)
csum <- csum + 0.01*VertexSize[names(csum)]
csum <- csum[order(-csum)]
tpsum <- min(130,length(csum))
csum <- rownames(transform)[rownames(transform) %in% names(csum[1:tpsum])]
csum <- unique(c(trsum,csum))
transform <- transform[csum,csum]
}
print(ncol(transform))
}
[1] 130
if (ncol(transform) < 150)
{
gplots::heatmap.2(transform,
trace = "none",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Red Decorrelation matrix",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Beta|>0",
xlab="Output Feature", ylab="Input Feature")
par(op)
VertexSize <- VertexSize[colnames(transform)]
gr <- graph_from_adjacency_matrix(transform,mode = "directed",diag = FALSE,weighted=TRUE)
gr$layout <- layout_with_fr
fc <- cluster_optimal(gr)
plot(fc, gr,
edge.width = 2*E(gr)$weight,
vertex.size=VertexSize,
edge.arrow.size=0.5,
edge.arrow.width=0.5,
vertex.label.cex=(0.15+0.05*VertexSize),
vertex.label.dist=0.5 + 0.05*VertexSize,
main="Top Feature Association")
varratios <- varratio
fscores <- fscore
names(varratios) <- str_remove_all(names(varratios),"La_")
names(fscores) <- str_remove_all(names(fscores),"La_")
dc <- getLatentCoefficients(DEdataframe)
theCharformulas <- attr(dc,"LatentCharFormulas")
clustable <- as.data.frame(cbind(Variable=fc$names,
Formula=as.character(theCharformulas[paste("La_",fc$names,sep="")]),
Class=fc$membership,
ResidualVariance=round(varratios[fc$names],3),
Fscore=round(fscores[fc$names],3)
)
)
rownames(clustable) <- str_replace_all(rownames(clustable),"__","_")
clustable$Variable <- NULL
clustable$Class <- as.integer(clustable$Class)
clustable$ResidualVariance <- as.numeric(clustable$ResidualVariance)
clustable$Fscore <- as.numeric(clustable$Fscore)
clustable <- clustable[order(-clustable$Fscore),]
clustable <- clustable[order(clustable$Class),]
clustable <- clustable[clustable$Fscore >= -1,]
topv <- min(50,nrow(clustable))
clustable <- clustable[1:topv,]
}
pander::pander(clustable)
| Formula | Class | ResidualVariance | Fscore | |
|---|---|---|---|---|
| app_LT_TKEO_mean_8_coef | NA | 1 | 1.000 | 60 |
| app_det_TKEO_mean_9_coef | + app_det_TKEO_mean_9_coef - (5.010)app_LT_TKEO_mean_8_coef | 1 | 0.021 | 12 |
| app_LT_TKEO_std_10_coef | - (0.998)app_LT_TKEO_mean_8_coef + app_LT_TKEO_std_10_coef | 1 | 0.000 | 9 |
| app_det_TKEO_mean_3_coef | + app_det_TKEO_mean_3_coef - (2.259)app_det_TKEO_mean_9_coef + (6.541)app_LT_TKEO_mean_8_coef | 1 | 0.031 | 6 |
| app_entropy_shannon_2_coef | + app_entropy_shannon_2_coef + (5.456)app_LT_TKEO_mean_8_coef | 1 | 0.029 | 2 |
| app_entropy_shannon_6_coef | + app_entropy_shannon_6_coef + (5.392)app_LT_TKEO_mean_8_coef | 1 | 0.019 | 2 |
| numPulses | + numPulses - (2.494)app_LT_TKEO_mean_8_coef | 1 | 0.237 | 1 |
| app_entropy_shannon_7_coef | - (1.009)app_entropy_shannon_6_coef + app_entropy_shannon_7_coef - (0.062)app_LT_TKEO_mean_8_coef | 1 | 0.000 | 1 |
| app_det_TKEO_mean_5_coef | + app_det_TKEO_mean_5_coef - (2.028)app_det_TKEO_mean_7_coef + (0.995)app_det_TKEO_mean_9_coef + (0.167)app_LT_TKEO_mean_8_coef | 1 | 0.001 | 1 |
| VFER_entropy | + VFER_entropy - (8.817)app_LT_TKEO_mean_8_coef | 1 | 0.297 | 0 |
| app_entropy_shannon_1_coef | + app_entropy_shannon_1_coef - (1.112)app_entropy_shannon_2_coef - (0.588)app_LT_TKEO_mean_8_coef | 1 | 0.000 | 0 |
| app_det_TKEO_mean_7_coef | + app_det_TKEO_mean_7_coef - (1.109)app_det_TKEO_mean_9_coef + (0.552)app_LT_TKEO_mean_8_coef | 1 | 0.001 | 0 |
| app_LT_TKEO_mean_10_coef | - (0.224)app_LT_TKEO_mean_8_coef + app_LT_TKEO_mean_10_coef - (0.777)app_LT_TKEO_std_10_coef | 1 | 0.000 | 0 |
| app_LT_TKEO_std_3_coef | - (0.976)app_LT_TKEO_mean_8_coef + app_LT_TKEO_std_3_coef | 1 | 0.061 | 0 |
| app_LT_TKEO_std_6_coef | - (0.997)app_LT_TKEO_mean_8_coef + app_LT_TKEO_std_6_coef | 1 | 0.007 | 0 |
| app_LT_entropy_shannon_8_coef | + (0.913)app_entropy_shannon_6_coef - (0.905)app_entropy_shannon_7_coef + app_LT_entropy_shannon_8_coef - (4.350)app_LT_TKEO_mean_8_coef + (5.527)app_LT_TKEO_std_10_coef | 1 | 0.001 | -1 |
| Ea | + Ea + (0.029)app_det_TKEO_mean_9_coef - (0.145)app_LT_TKEO_mean_8_coef | 1 | 0.225 | -1 |
| app_entropy_log_10_coef | + app_entropy_log_10_coef + (1.062)app_LT_TKEO_mean_8_coef - (1.361)app_LT_TKEO_std_10_coef | 1 | 0.003 | -1 |
| app_det_TKEO_mean_10_coef | - (0.915)app_det_TKEO_mean_9_coef + app_det_TKEO_mean_10_coef - (0.438)app_LT_TKEO_mean_8_coef | 1 | 0.000 | -1 |
| Ea2 | + Ea2 + (0.036)app_LT_TKEO_mean_8_coef - (0.162)app_LT_TKEO_mean_10_coef + (0.126)app_LT_TKEO_std_10_coef | 1 | 0.286 | -1 |
| det_LT_TKEO_mean_1_coef | NA | 2 | 1.000 | 22 |
| det_LT_TKEO_mean_4_coef | - (0.560)det_LT_TKEO_mean_1_coef + det_LT_TKEO_mean_4_coef | 2 | 0.136 | 5 |
| det_TKEO_mean_1_coef | + det_TKEO_mean_1_coef - (0.961)det_LT_TKEO_mean_1_coef - (4.648)app_LT_TKEO_mean_8_coef | 2 | 0.006 | 3 |
| det_LT_TKEO_mean_3_coef | - (0.655)det_LT_TKEO_mean_1_coef + det_LT_TKEO_mean_3_coef | 2 | 0.077 | 2 |
| Ed2_2_coef | + Ed2_2_coef - (0.791)det_LT_TKEO_mean_1_coef | 2 | 0.028 | 1 |
| det_TKEO_mean_2_coef | + det_TKEO_mean_2_coef - (0.774)det_LT_TKEO_mean_1_coef | 2 | 0.042 | 0 |
| det_TKEO_mean_3_coef | + det_TKEO_mean_3_coef - (0.617)det_LT_TKEO_mean_1_coef | 2 | 0.082 | 0 |
| Ed2_1_coef | + Ed2_1_coef - (0.980)det_LT_TKEO_mean_1_coef | 2 | 0.002 | 0 |
| det_TKEO_std_5_coef | - (1.039)det_TKEO_mean_1_coef + det_TKEO_std_5_coef - (0.920)Ed2_5_coef + (0.998)det_LT_TKEO_mean_1_coef | 2 | 0.011 | -1 |
| tqwt_stdValue_dec_35 | NA | 3 | 1.000 | 21 |
| tqwt_stdValue_dec_33 | + tqwt_stdValue_dec_33 - (0.783)tqwt_stdValue_dec_35 | 3 | 0.162 | 8 |
| tqwt_stdValue_dec_34 | + tqwt_stdValue_dec_34 - (0.936)tqwt_stdValue_dec_35 | 3 | 0.016 | 5 |
| tqwt_stdValue_dec_32 | + tqwt_stdValue_dec_32 - (0.963)tqwt_stdValue_dec_33 | 3 | 0.051 | 4 |
| tqwt_stdValue_dec_31 | + tqwt_stdValue_dec_31 - (1.872)tqwt_stdValue_dec_32 + (1.803)tqwt_stdValue_dec_33 - (1.690)tqwt_stdValue_dec_34 + (0.905)tqwt_stdValue_dec_35 | 3 | 0.034 | 1 |
| tqwt_minValue_dec_30 | + (0.571)tqwt_stdValue_dec_35 + tqwt_minValue_dec_30 | 3 | 0.315 | 1 |
| tqwt_energy_dec_35 | + tqwt_energy_dec_35 - (1.190)tqwt_stdValue_dec_35 | 3 | 0.347 | 0 |
| tqwt_entropy_shannon_dec_35 | + tqwt_entropy_shannon_dec_35 - (1.730)tqwt_stdValue_dec_35 | 3 | 0.005 | 0 |
| tqwt_entropy_log_dec_35 | + tqwt_entropy_log_dec_35 - (0.213)tqwt_stdValue_dec_35 | 3 | 0.128 | 0 |
| tqwt_TKEO_std_dec_35 | + tqwt_TKEO_std_dec_35 - (1.820)tqwt_stdValue_dec_35 | 3 | 0.039 | 0 |
| tqwt_stdValue_dec_36 | - (1.124)tqwt_stdValue_dec_35 + tqwt_stdValue_dec_36 | 3 | 0.049 | 0 |
| tqwt_minValue_dec_33 | + (0.897)tqwt_stdValue_dec_33 + tqwt_minValue_dec_33 | 3 | 0.090 | 0 |
| tqwt_minValue_dec_35 | + (0.892)tqwt_stdValue_dec_35 + tqwt_minValue_dec_35 | 3 | 0.053 | 0 |
| tqwt_maxValue_dec_8 | NA | 4 | 1.000 | 18 |
| tqwt_minValue_dec_3 | + tqwt_minValue_dec_3 + (0.806)tqwt_maxValue_dec_8 | 4 | 0.312 | 7 |
| tqwt_minValue_dec_12 | + tqwt_minValue_dec_12 + (0.880)tqwt_maxValue_dec_8 | 4 | 0.236 | 7 |
| tqwt_stdValue_dec_7 | + tqwt_stdValue_dec_7 - (1.185)tqwt_maxValue_dec_8 | 4 | 0.156 | 6 |
| tqwt_stdValue_dec_9 | + tqwt_stdValue_dec_9 - (1.051)tqwt_maxValue_dec_8 | 4 | 0.167 | 6 |
| tqwt_entropy_shannon_dec_6 | + tqwt_entropy_shannon_dec_6 - (2.278)tqwt_maxValue_dec_8 | 4 | 0.278 | 5 |
| tqwt_entropy_shannon_dec_11 | + tqwt_entropy_shannon_dec_11 - (1.652)tqwt_maxValue_dec_8 | 4 | 0.340 | 2 |
| tqwt_entropy_log_dec_8 | + tqwt_entropy_log_dec_8 - (0.170)tqwt_maxValue_dec_8 | 4 | 0.282 | 1 |
par(op)
if (!largeSet)
{
cormat <- cor(DEdataframe[,varlistc],method="pearson")
cormat[is.na(cormat)] <- 0
gplots::heatmap.2(abs(cormat),
trace = "none",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Correlation after ILAA",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Pearson Correlation|",
xlab="Feature", ylab="Feature")
par(op)
diag(cormat) <- 0
print(max(abs(cormat)))
}
[1]
0.79933
classes <- unique(dataframe[1:numsub,outcome])
raincolors <- rainbow(length(classes))
names(raincolors) <- classes
topvars <- univariate_BinEnsemble(dataframe,outcome)
lso <- LASSO_MIN(formula(paste(outcome,"~.")),dataframe,family="binomial")
topvars <- unique(c(names(topvars),lso$selectedfeatures))
pander::pander(head(topvars))
std_9th_delta_delta, tqwt_entropy_log_dec_12, std_delta_log_energy, std_delta_delta_log_energy, tqwt_TKEO_std_dec_12 and std_8th_delta_delta
# names(topvars)
#if (nrow(dataframe) < 1000)
#{
datasetframe.umap = umap(scale(dataframe[1:numsub,topvars]),n_components=2)
# datasetframe.umap = umap(dataframe[1:numsub,varlist],n_components=2)
plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: Original",t='n')
text(datasetframe.umap$layout,labels=dataframe[1:numsub,outcome],col=raincolors[dataframe[1:numsub,outcome]+1])
#}
varlistcV <- names(varratio[varratio >= 0.01])
topvars <- univariate_BinEnsemble(DEdataframe[,varlistcV],outcome)
lso <- LASSO_MIN(formula(paste(outcome,"~.")),DEdataframe[,varlistcV],family="binomial")
topvars <- unique(c(names(topvars),lso$selectedfeatures))
pander::pander(head(topvars))
std_delta_log_energy, La_tqwt_kurtosisValue_dec_33, La_tqwt_stdValue_dec_32, std_9th_delta, tqwt_entropy_log_dec_13 and mean_MFCC_2nd_coef
varlistcV <- varlistcV[varlistcV != outcome]
# DEdataframe[,outcome] <- as.numeric(DEdataframe[,outcome])
#if (nrow(dataframe) < 1000)
#{
datasetframe.umap = umap(scale(DEdataframe[1:numsub,topvars]),n_components=2)
# datasetframe.umap = umap(DEdataframe[1:numsub,varlistcV],n_components=2)
plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: After ILAA",t='n')
text(datasetframe.umap$layout,labels=DEdataframe[1:numsub,outcome],col=raincolors[DEdataframe[1:numsub,outcome]+1])
#}
univarRAW <- uniRankVar(varlist,
paste(outcome,"~1"),
outcome,
dataframe,
rankingTest="AUC")
100 : std_MFCC_2nd_coef 200 : app_entropy_log_3_coef 300 :
app_LT_TKEO_mean_7_coef 400 : tqwt_entropy_log_dec_15 500 :
tqwt_medianValue_dec_7
600 : tqwt_stdValue_dec_35 700 : tqwt_skewnessValue_dec_27
univarDe <- uniRankVar(varlistc,
paste(outcome,"~1"),
outcome,
DEdataframe,
rankingTest="AUC",
)
100 : La_std_MFCC_2nd_coef 200 : app_entropy_log_3_coef 300 :
La_app_LT_TKEO_mean_7_coef 400 : La_tqwt_entropy_log_dec_15 500 :
tqwt_medianValue_dec_7
600 : tqwt_stdValue_dec_35 700 : tqwt_skewnessValue_dec_27
univariate_columns <- c("caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC")
##top variables
topvar <- c(1:length(varlist)) <= TopVariables
tableRaw <- univarRAW$orderframe[topvar,univariate_columns]
pander::pander(tableRaw)
| caseMean | caseStd | controlMean | controlStd | controlKSP | ROCAUC | |
|---|---|---|---|---|---|---|
| std_delta_delta_log_energy | 23.4 | 0.469 | 22.8 | 0.461 | 0.653 | 0.798 |
| std_delta_log_energy | 24.3 | 0.477 | 23.8 | 0.441 | 0.634 | 0.794 |
| std_9th_delta_delta | 23.6 | 0.242 | 23.4 | 0.171 | 0.746 | 0.787 |
| std_8th_delta_delta | 23.7 | 0.240 | 23.4 | 0.150 | 0.725 | 0.780 |
| std_7th_delta_delta | 23.7 | 0.261 | 23.5 | 0.188 | 0.931 | 0.776 |
| tqwt_entropy_log_dec_12 | -39.6 | 0.239 | -39.4 | 0.240 | 0.887 | 0.770 |
| std_6th_delta_delta | 23.8 | 0.277 | 23.5 | 0.172 | 0.945 | 0.768 |
| std_8th_delta | 24.4 | 0.245 | 24.2 | 0.163 | 0.981 | 0.767 |
| std_9th_delta | 24.4 | 0.249 | 24.1 | 0.185 | 0.398 | 0.764 |
| tqwt_entropy_shannon_dec_12 | 30.3 | 1.993 | 32.1 | 1.703 | 0.196 | 0.763 |
topLAvar <- univarDe$orderframe$Name[str_detect(univarDe$orderframe$Name,"La_")]
topLAvar <- unique(c(univarDe$orderframe$Name[topvar],topLAvar[1:as.integer(TopVariables/2)]))
finalTable <- univarDe$orderframe[topLAvar,univariate_columns]
pander::pander(finalTable)
| caseMean | caseStd | controlMean | controlStd | controlKSP | ROCAUC | |
|---|---|---|---|---|---|---|
| std_delta_log_energy | 24.335 | 0.477 | 23.810 | 0.441 | 6.34e-01 | 0.794 |
| std_9th_delta | 24.365 | 0.249 | 24.134 | 0.185 | 3.98e-01 | 0.764 |
| La_tqwt_entropy_log_dec_28 | -0.633 | 0.430 | -0.819 | 0.273 | 1.25e-07 | 0.758 |
| tqwt_entropy_log_dec_13 | -39.232 | 0.280 | -38.985 | 0.259 | 7.85e-01 | 0.757 |
| mean_MFCC_2nd_coef | 21.360 | 18.112 | 1.716 | 27.881 | 4.61e-07 | 0.753 |
| La_tqwt_energy_dec_33 | 1.020 | 0.115 | 1.133 | 0.148 | 6.93e-01 | 0.746 |
| La_tqwt_kurtosisValue_dec_33 | 3.501 | 0.262 | 3.258 | 0.389 | 2.39e-01 | 0.746 |
| std_12th_delta | 24.239 | 0.239 | 24.055 | 0.193 | 3.42e-01 | 0.734 |
| La_apq11Shimmer | 2.150 | 0.161 | 2.031 | 0.133 | 4.19e-01 | 0.734 |
| La_tqwt_stdValue_dec_32 | 1.137 | 0.203 | 0.926 | 0.323 | 3.47e-01 | 0.733 |
dc <- getLatentCoefficients(DEdataframe)
fscores <- attr(DEdataframe,"fscore")
pander::pander(c(mean=mean(sapply(dc,length)),total=length(dc),fraction=length(dc)/(ncol(dataframe)-1)))
| mean | total | fraction |
|---|---|---|
| 2.65 | 460 | 0.617 |
theCharformulas <- attr(dc,"LatentCharFormulas")
topvar <- rownames(tableRaw)
finalTable <- rbind(finalTable,tableRaw[topvar[!(topvar %in% topLAvar)],univariate_columns])
orgnamez <- rownames(finalTable)
orgnamez <- str_remove_all(orgnamez,"La_")
finalTable$RAWAUC <- univarRAW$orderframe[orgnamez,"ROCAUC"]
finalTable$DecorFormula <- theCharformulas[rownames(finalTable)]
finalTable$fscores <- fscores[rownames(finalTable)]
finalTable$varratio <- varratio[rownames(finalTable)]
Final_Columns <- c("DecorFormula","caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC","RAWAUC","fscores","varratio")
finalTable <- finalTable[order(-finalTable$ROCAUC),]
pander::pander(finalTable[,Final_Columns])
| DecorFormula | caseMean | caseStd | controlMean | controlStd | controlKSP | ROCAUC | RAWAUC | fscores | varratio | |
|---|---|---|---|---|---|---|---|---|---|---|
| std_delta_delta_log_energy | NA | 23.357 | 0.469 | 22.794 | 0.461 | 6.53e-01 | 0.798 | 0.798 | NA | NA |
| std_delta_log_energy | NA | 24.335 | 0.477 | 23.810 | 0.441 | 6.34e-01 | 0.794 | 0.794 | 2 | 1.00000 |
| std_9th_delta_delta | NA | 23.630 | 0.242 | 23.388 | 0.171 | 7.46e-01 | 0.787 | 0.787 | NA | NA |
| std_8th_delta_delta | NA | 23.660 | 0.240 | 23.428 | 0.150 | 7.25e-01 | 0.780 | 0.780 | NA | NA |
| std_7th_delta_delta | NA | 23.732 | 0.261 | 23.479 | 0.188 | 9.31e-01 | 0.776 | 0.776 | NA | NA |
| tqwt_entropy_log_dec_12 | NA | -39.634 | 0.239 | -39.390 | 0.240 | 8.87e-01 | 0.770 | 0.770 | NA | NA |
| std_6th_delta_delta | NA | 23.800 | 0.277 | 23.548 | 0.172 | 9.45e-01 | 0.768 | 0.768 | NA | NA |
| std_8th_delta | NA | 24.406 | 0.245 | 24.175 | 0.163 | 9.81e-01 | 0.767 | 0.767 | NA | NA |
| std_9th_delta | NA | 24.365 | 0.249 | 24.134 | 0.185 | 3.98e-01 | 0.764 | 0.764 | 5 | 1.00000 |
| tqwt_entropy_shannon_dec_12 | NA | 30.301 | 1.993 | 32.106 | 1.703 | 1.96e-01 | 0.763 | 0.763 | NA | NA |
| La_tqwt_entropy_log_dec_28 | + tqwt_entropy_log_dec_28 - (0.981)tqwt_entropy_log_dec_29 | -0.633 | 0.430 | -0.819 | 0.273 | 1.25e-07 | 0.758 | 0.654 | -1 | 0.00858 |
| tqwt_entropy_log_dec_13 | NA | -39.232 | 0.280 | -38.985 | 0.259 | 7.85e-01 | 0.757 | 0.757 | 4 | 1.00000 |
| mean_MFCC_2nd_coef | NA | 21.360 | 18.112 | 1.716 | 27.881 | 4.61e-07 | 0.753 | 0.753 | 0 | 1.00000 |
| La_tqwt_energy_dec_33 | - (1.014)tqwt_energy_dec_32 + tqwt_energy_dec_33 + (1.770)tqwt_stdValue_dec_32 - (1.705)tqwt_stdValue_dec_33 | 1.020 | 0.115 | 1.133 | 0.148 | 6.93e-01 | 0.746 | 0.509 | -3 | 0.00454 |
| La_tqwt_kurtosisValue_dec_33 | - (0.887)tqwt_kurtosisValue_dec_32 + tqwt_kurtosisValue_dec_33 | 3.501 | 0.262 | 3.258 | 0.389 | 2.39e-01 | 0.746 | 0.628 | -1 | 0.12500 |
| std_12th_delta | NA | 24.239 | 0.239 | 24.055 | 0.193 | 3.42e-01 | 0.734 | 0.734 | 2 | 1.00000 |
| La_apq11Shimmer | - (0.907)locShimmer + apq11Shimmer | 2.150 | 0.161 | 2.031 | 0.133 | 4.19e-01 | 0.734 | 0.713 | -1 | 0.10276 |
| La_tqwt_stdValue_dec_32 | + tqwt_stdValue_dec_32 - (0.963)tqwt_stdValue_dec_33 | 1.137 | 0.203 | 0.926 | 0.323 | 3.47e-01 | 0.733 | 0.573 | 4 | 0.05089 |
featuresnames <- colnames(dataframe)[colnames(dataframe) != outcome]
pc <- prcomp(dataframe[,iscontinous],center = TRUE,scale. = TRUE,tol=0.01) #principal components
predPCA <- predict(pc,dataframe[,iscontinous])
PCAdataframe <- as.data.frame(cbind(predPCA,dataframe[,!iscontinous]))
colnames(PCAdataframe) <- c(colnames(predPCA),colnames(dataframe)[!iscontinous])
#plot(PCAdataframe[,colnames(PCAdataframe)!=outcome],col=dataframe[,outcome],cex=0.65,cex.lab=0.5,cex.axis=0.75,cex.sub=0.5,cex.main=0.75)
#pander::pander(pc$rotation)
PCACor <- cor(PCAdataframe[,colnames(PCAdataframe) != outcome])
gplots::heatmap.2(abs(PCACor),
trace = "none",
# scale = "row",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "PCA Correlation",
cexRow = 0.5,
cexCol = 0.5,
srtCol=45,
srtRow= -45,
key.title=NA,
key.xlab="Pearson Correlation",
xlab="Feature", ylab="Feature")
EFAdataframe <- dataframeScaled
if (length(iscontinous) < 2000)
{
topred <- min(length(iscontinous),nrow(dataframeScaled),ncol(predPCA)-1)
if (topred < 2) topred <- 2
uls <- fa(dataframeScaled[,iscontinous],nfactors=topred,rotate="varimax",warnings=FALSE) # EFA analysis
predEFA <- predict(uls,dataframeScaled[,iscontinous])
EFAdataframe <- as.data.frame(cbind(predEFA,dataframeScaled[,!iscontinous]))
colnames(EFAdataframe) <- c(colnames(predEFA),colnames(dataframeScaled)[!iscontinous])
EFACor <- cor(EFAdataframe[,colnames(EFAdataframe) != outcome])
gplots::heatmap.2(abs(EFACor),
trace = "none",
# scale = "row",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "EFA Correlation",
cexRow = 0.5,
cexCol = 0.5,
srtCol=45,
srtRow= -45,
key.title=NA,
key.xlab="Pearson Correlation",
xlab="Feature", ylab="Feature")
}
par(op)
par(xpd = TRUE)
dataframe[,outcome] <- factor(dataframe[,outcome])
rawmodel <- rpart(paste(outcome,"~."),dataframe,control=rpart.control(maxdepth=3))
pr <- predict(rawmodel,dataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(rawmodel,main="Raw",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(rawmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,dataframe[,outcome]==0))
}
pander::pander(table(dataframe[,outcome],pr))
| 0 | 1 | |
|---|---|---|
| 0 | 39 | 25 |
| 1 | 3 | 185 |
pander::pander(ptab$detail[c(5,3,4,6),])
| statistic | est | lower | upper | |
|---|---|---|---|---|
| 5 | diag.ac | 0.889 | 0.843 | 0.925 |
| 3 | se | 0.984 | 0.954 | 0.997 |
| 4 | sp | 0.609 | 0.479 | 0.729 |
| 6 | diag.or | 96.200 | 27.662 | 334.550 |
par(op)
par(xpd = TRUE)
DEdataframe[,outcome] <- factor(DEdataframe[,outcome])
IDeAmodel <- rpart(paste(outcome,"~."),DEdataframe[,c(outcome,varlistcV)],control=rpart.control(maxdepth=3))
pr <- predict(IDeAmodel,DEdataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(IDeAmodel,main="ILAA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(IDeAmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,DEdataframe[,outcome]==0))
}
pander::pander(table(DEdataframe[,outcome],pr))
| 0 | 1 | |
|---|---|---|
| 0 | 52 | 12 |
| 1 | 12 | 176 |
pander::pander(ptab$detail[c(5,3,4,6),])
| statistic | est | lower | upper | |
|---|---|---|---|---|
| 5 | diag.ac | 0.905 | 0.862 | 0.938 |
| 3 | se | 0.936 | 0.891 | 0.967 |
| 4 | sp | 0.812 | 0.695 | 0.899 |
| 6 | diag.or | 63.556 | 26.952 | 149.873 |
par(op)
par(xpd = TRUE)
PCAdataframe[,outcome] <- factor(PCAdataframe[,outcome])
PCAmodel <- rpart(paste(outcome,"~."),PCAdataframe,control=rpart.control(maxdepth=3))
pr <- predict(PCAmodel,PCAdataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(PCAmodel,main="PCA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(PCAmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,PCAdataframe[,outcome]==0))
}
pander::pander(table(PCAdataframe[,outcome],pr))
| 0 | 1 | |
|---|---|---|
| 0 | 40 | 24 |
| 1 | 14 | 174 |
pander::pander(ptab$detail[c(5,3,4,6),])
| statistic | est | lower | upper | |
|---|---|---|---|---|
| 5 | diag.ac | 0.849 | 0.799 | 0.891 |
| 3 | se | 0.926 | 0.878 | 0.959 |
| 4 | sp | 0.625 | 0.495 | 0.743 |
| 6 | diag.or | 20.714 | 9.850 | 43.561 |
par(op)
EFAdataframe[,outcome] <- factor(EFAdataframe[,outcome])
EFAmodel <- rpart(paste(outcome,"~."),EFAdataframe,control=rpart.control(maxdepth=3))
pr <- predict(EFAmodel,EFAdataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(EFAmodel,main="EFA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(EFAmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,EFAdataframe[,outcome]==0))
}
pander::pander(table(EFAdataframe[,outcome],pr))
| 0 | 1 | |
|---|---|---|
| 0 | 32 | 32 |
| 1 | 5 | 183 |
pander::pander(ptab$detail[c(5,3,4,6),])
| statistic | est | lower | upper | |
|---|---|---|---|---|
| 5 | diag.ac | 0.853 | 0.803 | 0.894 |
| 3 | se | 0.973 | 0.939 | 0.991 |
| 4 | sp | 0.500 | 0.372 | 0.628 |
| 6 | diag.or | 36.600 | 13.269 | 100.950 |
par(op)